package com.security.one_way_encry.md5;

import org.springframework.util.DigestUtils;


/**
 * @ClassName TestMD5BySpring
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/23
 * @Version 1.0
 */
public class TestMD5BySpring {
    public static void main(String[] args) throws Exception {
        //5d41402abc4b2a76b9719d911017c592
        System.out.println(encryptMD5("hello"));
    }

    /**
     * 使用Spring的util包下的工具类进行加密
     * @param key
     * @return
     * @throws Exception
     */
    public static String encryptMD5(String key) throws Exception {
        return DigestUtils.md5DigestAsHex(key.getBytes());
    }

}
